package main

import (
	"flag"
	"judge-service/configs"
	"judge-service/httpsrv"
	"judge-service/rpcsrv"
	"path"
	"runtime"
)

func main() {

	// 加载配置文件
	var configFile string
	flag.StringVar(&configFile, "conf", "", "config file")
	flag.Parse()

	// 如果没有传入配置文件路径，则加载当前目录下的 /configs/config.json
	if len(configFile) == 0 {
		_, file, _, _ := runtime.Caller(0)
		configFile = path.Dir(file) + "/configs/config.json"
	}
	configs.LoadConfig(configFile)

	// 启动rpc服务
	go rpcsrv.ReportServe()

	// 启动聚合函数的http服务
	httpsrv.AggregateServe()

}
